<?php

namespace Home\Controller;
use Common\Controller\BaseController;

/**
 * 应用前台基类
 *
 * 前台所有的控制器都继承该类
 * 在该类中实现一些初始化操作
 *
 * @author: xuhui <xuh86@126.com>
 * @version: $Id$
 * @package: asoc.Home.Controller
 *
 */

class MainController extends BaseController {

    protected $visitor;         //访问者是移动端还是PC端 mo、pc

	function _initialize()
    {
		parent::_initialize();

        //确认访问来源 mo移动端 pc电脑端
        $visitor = cookie("visitor");
        if($visitor == "")
        {
            $visitor = is_mobile() ? "mo" : "pc";
            cookie("visitor",$visitor);
        }
        $this->visitor = $visitor;

        //前台资源路径
        $this->_FESrcPath =	$this->_RPath . 'theme/Home/'.$visitor.'/Public/';
        $this->assign('_FESrcPath',$this->_FESrcPath);
		
		//输出菜单
		$cModel = M('Category');
		$menuList = $cModel->where("parent_id=1")->order("node_order DESC,node_id")->select();
		foreach($menuList AS $key=>$val){
			$menuList[$key]['submenu'] = $cModel->where("parent_id={$val['node_id']}")->order("node_order DESC,node_id")->select();
		}
		$this->assign('menuList',$menuList);
	}

}